Skip to content

Fix CLI template names with trailing root separators - #2188

Open
sergioperezcheco wants to merge 2 commits into
handlebars-lang:masterfrom
sergioperezcheco:fix/cli-root-separators
Open

sergioperezcheco wants to merge 2 commits into
handlebars-lang:masterfrom
sergioperezcheco:fix/cli-root-separators

Conversation

@sergioperezcheco

@sergioperezcheco sergioperezcheco commented Oct 8, 2026 •

Copy link
Copy Markdown

Passing a trailing slash to the CLI's --root dropped the first character of template names. Root stripping now respects directory boundaries and both native and constructed separators, retaining / in stripped nested names while leaving unmatched roots and source paths unchanged.

Regression tests cover trailing roots, directory enumeration, partial directory-prefix matches and native Windows backslash paths. On Node 22.22.3, the previous implementation fails the two added Windows tests and the independent CLI reproduction; the fixed Windows target passes all 33 tests, the complete default test/build suite passes 656 with 27 skips, and lint/types plus nine real CLI compile-and-render cases pass. macOS default tests/build pass 654 with 29 skips, lint/types and eight public CLI cases pass; browser tests, Linux integration, publish/cloud tests and the full Node/OS matrix were not run locally.

This contribution was developed and tested by an autonomous AI agent; it has not received human review.

Assisted-by: Hermes Agent
Signed-off-by: sergioperezcheco <checo520@outlook.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new root-boundary logic does not support native Windows backslash separators.

1 open finding
What changed in this PR

Fixes CLI template-name corruption when --root has a trailing separator or only partially matches a directory name.

Changes:

  • Makes root stripping directory-boundary aware.
  • Adds regression coverage for trailing roots, nested names, and partial matches.
  • Preserves directory enumeration behavior.
File Description
lib/​precompiler.js Refines root-prefix removal.
spec/​precompiler.js Adds root-handling regression tests.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/precompiler.js Resolved
Assisted-by: Hermes Agent (Nous Research)
Signed-off-by: sergioperezcheco <checo520@outlook.com>
@sergioperezcheco

Copy link
Copy Markdown
Author

Recognized the native separator for root matching and kept / for names assembled during directory enumeration. The added Windows regression fails twice with the previous implementation and passes with this change; the full Windows default suite/build (656 passed, 27 skipped), lint/types and nine CLI compile-and-render cases also pass on Node 22.22.3. The macOS default suite/build and lint/types pass too; mismatched roots still preserve their original names, and POSIX literal backslashes remain ordinary filename characters. Browser, Linux integration and the full Node/OS matrix were not run locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix has relevant regression coverage and no identified blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants